/*
 * @Author: lixiaowei
 * @Date: 2021-04-09 15:44:11
 * @LastEditors: lixiaowei
 * @LastEditTime: 2021-04-09 15:58:39
 * @Description: file content
 * @FilePath: /heima-bli/STL/关联式容器.cpp
 */

#include <iostream>
#include <string>
#include <map>

using namespace std;

struct Display
{
  void operator()(pair<string, double> info) {
    cout << info.first << " : " << info.second << endl;
  }
};


int main() {

  map<string, double> stuScore;

  stuScore["zhangsan"] = 94.5;
  stuScore["wangwu"] = 90.5;
  stuScore["zhangkai"] = 91.5;
  stuScore.insert(pair<string, double>("zhuqi", 89.1));
  stuScore.insert(pair<string, double>("zhuqi", 90.1));
  stuScore["zhuqi"] = 90.5;

  for_each(stuScore.begin(), stuScore.end(), Display());
  cout << endl;

  map<string, double>::iterator itr;

  itr = stuScore.begin();
	while (itr != stuScore.end())
	{
		if (itr->second < 98.0) 
		{
			stuScore.erase(itr++);
		}
		else
		{
			itr++;
		}
	}
	for_each(stuScore.begin(), stuScore.end(), Display());
	cout << endl;


  for (itr = stuScore.begin(); itr != stuScore.end(); itr++)
  {
    // cout << itr->first << " : " << itr->second << endl;
    if (itr->second < 91.0) 
    {
      stuScore.erase(itr);
    }
    
  }

  for_each(stuScore.begin(), stuScore.end(), Display());
  cout << endl;
  

  return 0;
}